package io3;
/**
 * 缓冲流实现文件的复制
 */

import java.io.*;

public class CopyDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("note.txt");
        BufferedInputStream bis=new BufferedInputStream(fis);
        FileOutputStream fos=new FileOutputStream("note_cp2.txt");
        BufferedOutputStream bos=new BufferedOutputStream(fos);
        long start=System.currentTimeMillis();
        int d;
        while ((d=bis.read())!=-1){
            bos.write(d);
        }
        long end=System.currentTimeMillis();
        System.out.println("复制所耗时"+(end-start)+"ms");
        bis.close();
        bos.close();






















//        FileInputStream fis=new FileInputStream("no.txt");
//        BufferedInputStream bis=new BufferedInputStream(fis);
//        FileOutputStream fos=new FileOutputStream("no_cp2.txt");
//        BufferedOutputStream bos=new BufferedOutputStream(fos);
//        long start=System.currentTimeMillis();
//        int d;
//        while ((d=bis.read())!=-1){
//            bos.write(d);
//        }
//        long end=System.currentTimeMillis();
//        System.out.println("复制所耗时"+(end-start)+"ms");
//        bis.close();
//        bos.close();

//        FileInputStream fis=new FileInputStream("ok.txt");
//        BufferedInputStream bis=new BufferedInputStream(fis);
//        FileOutputStream fos=new FileOutputStream("ok_cp3.txt");
//        BufferedOutputStream bos=new BufferedOutputStream(fos);
//        long start=System.currentTimeMillis();
//        int d;
//        while ((d=bis.read())!=-1){
//            bos.write(d);
//        }
//        long end=System.currentTimeMillis();
//        System.out.println("复制的时间为"+(end-start)+"ms");
//        bos.close();
//        bis.close();
    }
}
